<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class news_topics_list_model extends Model
{
	var $url_prefix = 'admin/news_topics.news_topics.lists';
	var $url_prefix2 = 'admin/news_topics.news_topics.detail';
	var $start_segment = 3;
	var $start;
	var $msg_cache_prefix = 'msg';
	var $cache;
	var $cache_name = 'news_topics';
	var $columns = array();
	var $item_segment = 4;
	var $error_string = '';
	var $_table_name = TOPIC;
	
	function news_topics_list_model()
	{
		parent::Model();
		
		global $CI;
		//check language
		$language = $CI->uri->segment(3);
		if($language=="english"){
			$this->url_prefix2 = $this->url_prefix2."/english";
			$this->url_prefix = $this->url_prefix."/english";
			$this->start_segment = $this->start_segment+1;
			$this->item_segment = $this->item_segment+1;
			$this->_table_name = $this->_table_name."_en";			
		}
		//end check
		$start = $CI->uri->segment($this->start_segment);
		$this->start = $start?$start:0;
		
		$this->cache = new Session_lite($this->cache_name);
		
		$this->columns = array(
			'id'=>$this->_table_name.'.'.TOPIC_ID,
			'name'=>$this->_table_name.'.'.TOPIC_NAME,
			'description'=>$this->_table_name.'.'.TOPIC_DESCRIPTION
		);
		
	}
	
	function admin_id()
	{
		global $CI;
		$a = $CI->session->userdata('admin_auth_logged');
		return $a['admin_id'];
	}
	
		
	function check_delete($id)
	{
		$q = $this->db->get_where($this->_table_name, array(TOPIC_ID=>$id));
		if ($q->num_rows()<1)
		{
			$this->error_string .= "Mục đang xóa không tồn tại trong hệ thống.";
			return false;
		}
		
		return true;
	}
}

?>
